package com.sali.DP;

/**
 剪绳子
 */
public class JZ_14 {

    public int cutRope (int n) {
        int[] dp = new int[n + 1];
        dp[1] = 1;
        dp[2] = 2;
        dp[3] = 3;
        dp[4] = 4;
        for ( int i = 5; i <=n; i++ ) {
            for ( int j = 1; j < i; j++ ) {
                dp[i] = Math.max(dp[i], dp[i-j] * j);
            }
        }
        return dp[n];
    }

}
